﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" 
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                    mc:Ignorable="d">
	<!-- Resource dictionary entries should be defined here. -->
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Colors.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="ImageToggleButtonStyle" TargetType="{x:Type ToggleButton}">
        <Setter Property="MinWidth" Value="20"/>
        <Setter Property="MinHeight" Value="20"/>
        <Setter Property="Template" Value="{DynamicResource {ComponentResourceKey ResourceId=ImageToggleButtonTemplate, TypeInTargetAssembly={x:Type ToggleButton}}}"/>
	</Style>

    <ControlTemplate x:Key="{ComponentResourceKey ResourceId=ImageToggleButtonTemplate, TypeInTargetAssembly={x:Type ToggleButton}}" TargetType="{x:Type ToggleButton}">
        <Grid x:Name="MainGrid" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
    		<VisualStateManager.VisualStateGroups>
    			<VisualStateGroup x:Name="CommonStates">
    				<VisualStateGroup.Transitions>
    					<VisualTransition From="Normal" GeneratedDuration="0:0:0.4" To="MouseOver"/>
    					<VisualTransition From="MouseOver" GeneratedDuration="0:0:0.4" To="Normal"/>
    					<VisualTransition From="MouseOver" GeneratedDuration="0:0:0.2" To="Pressed"/>
    					<VisualTransition From="Pressed" GeneratedDuration="0:0:0.2" To="MouseOver"/>
    				</VisualStateGroup.Transitions>
    				<VisualState x:Name="Normal"/>
    				<VisualState x:Name="MouseOver">
    					<Storyboard>
    						<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="ButtonBorder">
    							<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_Control_Background_Move}"/>
    						</ColorAnimationUsingKeyFrames>
    					</Storyboard>
    				</VisualState>
    				<VisualState x:Name="Pressed">
    					<Storyboard>
    						<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="ButtonBorder">
    							<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_Control_Background_Pressed}"/>
    						</ColorAnimationUsingKeyFrames>
    					</Storyboard>
    				</VisualState>
    				<VisualState x:Name="Disabled">
    					<Storyboard>
    						<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="ButtonBorder">
    							<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_Control_Background_Disabled}"/>
    						</ColorAnimationUsingKeyFrames>
    					</Storyboard>
    				</VisualState>
    			</VisualStateGroup>
    			<VisualStateGroup x:Name="FocusStates">
    				<VisualStateGroup.Transitions>
    					<VisualTransition From="Focused" GeneratedDuration="0:0:0.2" To="Unfocused"/>
    					<VisualTransition From="Unfocused" GeneratedDuration="0:0:0.2" To="Focused"/>
    				</VisualStateGroup.Transitions>
    				<VisualState x:Name="Unfocused"/>
    				<VisualState x:Name="Focused">
    					<Storyboard>
    						<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="FocusBorder">
    							<EasingDoubleKeyFrame KeyTime="0" Value="0.5"/>
    						</DoubleAnimationUsingKeyFrames>
    					</Storyboard>
    				</VisualState>
    			</VisualStateGroup>
    			<VisualStateGroup x:Name="CheckStates">
    				<VisualStateGroup.Transitions>
    					<VisualTransition From="Unchecked" GeneratedDuration="0:0:0.3" To="Checked"/>
    					<VisualTransition From="Checked" GeneratedDuration="0:0:0.3" To="Unchecked"/>
    				</VisualStateGroup.Transitions>
    				<VisualState x:Name="Checked">
    					<Storyboard>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="CheckedBorder">
    							<EasingDoubleKeyFrame KeyTime="0" Value="1"/>
    						</DoubleAnimationUsingKeyFrames>
    					</Storyboard>
    				</VisualState>
    				<VisualState x:Name="Unchecked"/>
    				<VisualState x:Name="Indeterminate">
    					<Storyboard>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="CheckedBorder">
    							<EasingDoubleKeyFrame KeyTime="0" Value="1"/>
    						</DoubleAnimationUsingKeyFrames>
    					</Storyboard>
    				</VisualState>
    			</VisualStateGroup>
    		</VisualStateManager.VisualStateGroups>
    		<Border x:Name="ButtonBorder" BorderThickness="1" CornerRadius="2" Height="Auto" Width="Auto" Margin="0">
    			<Border.BorderBrush>
    				<SolidColorBrush Color="{StaticResource Application_Control_BorderBrush}"/>
    			</Border.BorderBrush>
    			<Border.Background>
    				<SolidColorBrush Color="{StaticResource Application_Control_Background}"/>
    			</Border.Background>
    		</Border>
    		<Border x:Name="CheckedBorder" BorderThickness="2" Margin="0" Visibility="Visible" CornerRadius="2" Opacity="0">
    			<Border.Background>
    				<SolidColorBrush Color="{StaticResource Application_ToggleButton_BorderBrush_Selection}"/>
    			</Border.Background>
    			<Border.BorderBrush>
    				<SolidColorBrush Color="{StaticResource Application_ToggleButton_Background_Selection}"/>
    			</Border.BorderBrush>
    		</Border>
    		<ContentPresenter RecognizesAccessKey="True" Content="{TemplateBinding Content}" VerticalAlignment="Center" 
    			HorizontalAlignment="Center" ContentTemplate="{TemplateBinding ContentTemplate}" Margin="2" IsHitTestVisible="False"/>
    		<Border x:Name="FocusBorder" BorderThickness="1" CornerRadius="2" Opacity="0" Visibility="Visible">
    			<Border.BorderBrush>
    				<SolidColorBrush Color="{StaticResource Application_Control_BorderBrush_Focus}"/>
    			</Border.BorderBrush>
    		</Border>
    	</Grid>
    </ControlTemplate>
</ResourceDictionary>